package cn.lixu.basic.interceptor.config;

import cn.lixu.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author LiXu
 * @date 2022/07/31 0031 0:27:44
 * 相当于当前的类是配置类  xml文件
 */
@Configuration
public class MyConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //添加拦截器
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") //拦截路径
                .excludePathPatterns("/fastdfs/**") // 放行路径
                .excludePathPatterns("/login/**")// 放行路径
                .excludePathPatterns("/verifyCode/**")// 放行路径
                .excludePathPatterns("/shop/settlement")// 放行路径
                .excludePathPatterns("/user/phoneRegister")// 放行路径
                .excludePathPatterns("/swagger-resources/**", "/webjars/**",
                        "/v2/**", "/swagger-ui.html/**");// 放行路径


    }
}
